package com.cs.controller;



import com.cs.dto.ClassifyDto;
import com.cs.dto.Result;
import com.cs.service.ClassifyService;
import com.cs.entity.Classify;
import com.cs.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品分类 前端控制器
 * </p>
 *
 * @author cs
 * @since 2021-08-05
 */
@RestController
@RequestMapping("/api/home")
public class ClassifyController {
    @Autowired
    private ClassifyService classifyService;

    @GetMapping("all")
    public List<Classify> findAll(){
        List<Classify> list = classifyService.list();
        return list;
    }

    @GetMapping("classifyTree")
    public Result<List<Classify>> findClasssifyTree(){
        List<ClassifyDto> list = classifyService.getClassifyTree();
        return ResultUtils.returnDataSuccess(list);
    }

}

